<?php

/**
 * SearchController: searching Blog, News and Products
 */
class AjaxController extends CustomControllerBase {
	/**
	 * UserCountryDataService object
	 *
	 * @var UserCountryDataService object
	 */
	private $userCountryDataService = null;
	
	/**
	 * UserStateDataService object
	 *
	 * @var UserStateDataService object
	 */
	private $userStateDataService = null;
	/**
	 * Constructor of index
	 */
	public function __construct() {
		parent::__construct ();
		
		// Init All DaatService
		$this->userCountryDataService = new CountryDataService ();
		$this->userStateDataService = new StateDataService ();
	}
	
	/**
	 * The "statebycountry" action is get all state by country id
	 * 
	 *
	 * @return list state 
	 */
	public function statebycountryAction() {
		
		$countryId = $this->getPost ( 'countryId', '0' );
		
		$arrElement = array ();
		$arrElement ['countryId'] = $countryId;
		$lstState = $this->userStateDataService->getItems ( $arrElement );
		$this->smarty->assign ( 'lstState', $lstState );
		//$this->assignSmartyContent('Ajax/statebycountry.tpl');		
		$layoutPath = APPLICATION_PATH . "/Views/Templates/Browse/Ajax/signup.tpl";
		$this->smarty->display ( $layoutPath );
	}

}
